export const getUserRole = (): string | null => {
    const userInfoString = localStorage.getItem('userInfo');
    if (userInfoString) {
        try {
            const userInfo = JSON.parse(userInfoString);
            return userInfo.role || null;
        } catch (error) {
            console.error('Failed to parse userInfo from localStorage', error);
            return null;
        }
    }
    return null;
};

export const isAdmin = (): boolean => {
    return getUserRole() === 'admin';
};